import 'dart:io';

import 'package:flutter/material.dart';

void main() {
  runApp(new SwitchListTilePlugin());
}

/*
 * 初始化页 <br/>
 * 需要传入的键：<br/>
 * 传入的值类型： <br/>
 * 传入的值含义：<br/>
 * 是否必传 ：
 */
class SwitchListTilePlugin extends StatefulWidget {
  State<StatefulWidget> createState() {
    return new SwitchListTilePluginState();
  }
}

/*
 * 页面功能 <br/>
 */
class SwitchListTilePluginState extends State<StatefulWidget> {
  bool isSelected = true;

  void initState() {
    super.initState();
  }

  Widget build(BuildContext context) {
    AppBar appBar = AppBar(
      leading: new IconButton(
        icon: new Icon(Icons.arrow_back),
        onPressed: () {},
      ),
      title: new Text('FlutterDesign'),
      centerTitle: true,
      actions: <Widget>[
        new Container(width: 0, height: 0),
        new Container(width: 0, height: 0),
      ],
      backgroundColor: Colors.blue,
    );

    return MaterialApp(
      home: new Scaffold(
        appBar: appBar,
        body: new Builder(builder: (BuildContext context) {
          return SwitchListTile(
            value: isSelected,
            onChanged: (bool value) {
              setState(() {
                isSelected = value;
              });
            },
            secondary: Icon(
              Icons.add_alarm,
              color: Colors.orange[200],
            ),
            title: new Text("主标题"),
            subtitle: new Text("标题副s标题副s标题副s标题副s标题副s标题"),
            dense: false,
            activeColor: Colors.green[200],
            // 指定选中时的颜色
            activeTrackColor: Colors.blue[200],
            inactiveTrackColor: Colors.orange[200],
            inactiveThumbColor: Colors.red[200],
            inactiveThumbImage: AssetImage("images/avatar.jpg"),
            isThreeLine: true,
            // 是否空出第三行
            selected: true,
          );
        }),
        backgroundColor: Colors.white,
        bottomNavigationBar: null,
      ),
    );
  }
}
